package com.wxapp.admin.service.controller;

import com.wxapp.admin.api.pojo.vo.roleUser.QRoleUserSaveVo;
import com.wxapp.admin.service.service.UserRoleService;
import com.wxapp.common.constant.base.IBaseController;
import com.wxapp.common.constant.pojo.vm.PSimpleListVm;
import com.wxapp.common.constant.pojo.vm.ResultVm;
import com.wxapp.common.constant.pojo.vo.UserVo;
import com.wxapp.common.core.annotation.User;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author lgl
 * @Description 用户部门关联
 * @Datetime 2022/8/6 17:04
 * @Modified By
 */
@RequestMapping("/user/role")
@Tag(name = "用户部门角色关联管理")
@RestController
@RequiredArgsConstructor
public class UserRoleController extends IBaseController {
    private final UserRoleService userRoleService;

    @PostMapping("/add")
    @Operation(summary ="用户添加角色")
    public ResultVm<String> addUserRole(@Schema(hidden = true) @User UserVo userVo, @RequestBody QRoleUserSaveVo qRoleUserSaveVo) {
        return userRoleService.addUserRole(userVo, qRoleUserSaveVo);
    }

    @GetMapping("/bindRole")
    @Operation(summary ="获取下拉框角色和id 除去已经绑定的")
    public ResultVm<List<PSimpleListVm>> bindRole() {
        return userRoleService.bindRole();
    }

}
